<?php
/**
* Products Controller
*/
class Products extends CI_Controller {
	private $data = array();
	
    public function __construct() {
	    parent::__construct();
	}
	
	/**
	* product
	* Gathers data for a specific product to be shown.
	*/
	public function product( $productId ) {
		// Sets the basetitle for the page.
		$this->data['baseTitle'] = 'Webbshop';
		
		// Gets the count for totalt items in the cart.
		$this->data['cartTotal'] = $this->cart->total_items();
		
		// Loads the products_model and auto-connects to the database.
		$this->load->model( 'products_model', '', TRUE );
		
		// Retrives the item from the database with the specified ProductID.
		$this->data['product'] = $this->products_model->GetProductById( $productId );
		
		// Sets the pageTitle to the name of the product.        
		$this->data['pageTitle'] = $this->data['product'][0]['Name'];
		
		$this->load->view( 'product', $this->data );
	}
}